import 'package:flutter/cupertino.dart';
import 'package:flutterDemo/repository/api.dart';
import 'package:flutterDemo/repository/datas/common_website_data.dart';
import 'package:flutterDemo/repository/datas/search_hot_key_data.dart';

class HotKeyViewModel with ChangeNotifier {
  //混入
  List<CommonWebsiteData>? websiteList;
  List<SearchHotKeyData>? keyList;

  ///获取数据
  Future initData() async {
    getWebsiteList().then((value) => { 
          getSearchHotKeys().then((value) => {notifyListeners()})
        });
  }

  ///获取常用网站数据
  Future getWebsiteList() async {
    websiteList = await Api.instance.getWebsiteList();
    notifyListeners();
  }

  ///获取搜索热点数据
  Future getSearchHotKeys() async {
    keyList = await Api.instance.getSearchHotKeys();
    notifyListeners();
  }
}
